package com.SouthernWall_404.AgeDust.Common.Event;

import com.SouthernWall_404.AgeDust.Common.API.Capability.PlayerPersonality;
import com.SouthernWall_404.AgeDust.Common.API.Capability.PlayerPersonalityProvider;
import com.SouthernWall_404.AgeDust.Common.AgeDust;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class AttachCapabilityEvent {

    @SubscribeEvent
    public static void onAttachCapabilityEvent(AttachCapabilitiesEvent event)
    {
         if(event.getObject()instanceof Player player)
         {
             if(!player.getCapability(PlayerPersonalityProvider.PLAYER_PERSONALITY_CAPABILITY).isPresent())
             {
                event.addCapability(new ResourceLocation(AgeDust.MODID,"player_personality"),new PlayerPersonalityProvider());
             }
         }
    }
}
